<?php

namespace Tbf\Bundle\UploadBundle\Service;

use Tbf\Bundle\UploadBundle\LocalFileSaver;
use Tbf\Component\Path\PathFunction;

class LocalFileSave
{
    protected $base_path;
    protected $base_url;
    public function __construct($base_path,$base_url)
    {
        $this->base_path = $base_path;
        $this->base_url = $base_url;
    }

    /**
     * @param $ref_path string 相对路径,此处不能填绝对路径
     */
    public function newSaver($ref_path)
    {
        return new LocalFileSaver(PathFunction::filePathJoin($this->base_path,$ref_path),
            PathFunction::urlJoin($this->base_url,$ref_path));
    }
}
